public class SearchForRange {

	public int[] searchRange(int[] A, int target) {
		int n = A.length;
		int[] idx = new int[] { -1, -1 };
		int l = 0, r = n - 1, mid;
		while (l <= r) {
			mid = l + r >> 1;
			if (A[mid] < target) {
				l = mid + 1;
			} else {
				r = mid - 1;
			}
		}
		if (l < n && A[l] == target)
			idx[0] = l;

		l = 0;
		r = n - 1;
		while (l <= r) {
			mid = l + r >> 1;
			if (A[mid] <= target) {
				l = mid + 1;
			} else {
				r = mid - 1;
			}
		}
		if (l > 0 && A[l - 1] == target)
			idx[1] = l - 1;
		return idx;
	}

	public static void main(String[] args) {

	}

}
